home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 December / PCWorld_2007-12_cd.bin / domacnost a kancelar / autoit / autoit-v3-setup.exe / Examples / Helpfile / _IEDocInsertText.au3 < prev    next >
Text File  |  2007-09-08  |  3KB  |  70 lines

  1. ; *******************************************************
  2. ; Example 1 - Open a browser with the basic example page, insert text
  3. ;        in and around the first Paragraph tag and display Body HTML
  4. ; *******************************************************
  5. ;
  6. #include <IE.au3>
  7. $oIE = _IE_Example ("basic")
  8. $oP = _IETagNameGetCollection($oIE, "p", 0)
  9.  
  10. _IEDocInsertText($oP, "(Text beforebegin)", "beforebegin")
  11. _IEDocInsertText($oP, "(Text afterbegin)", "afterbegin")
  12. _IEDocInsertText($oP, "(Text beforeend)", "beforeend")
  13. _IEDocInsertText($oP, "(Text afterend)", "afterend")
  14.  
  15. ConsoleWrite(_IEBodyReadHTML($oIE) & @CR)
  16.  
  17. ; *******************************************************
  18. ; Example 2 - Insert HTML at the top and bottom of a document
  19. ; *******************************************************
  20. ;
  21. #include <IE.au3>
  22. $oIE = _IE_Example ("basic")
  23. $oBody = _IETagNameGetCollection($oIE, "body", 0)
  24. _IEDocInsertText($oBody, "This Text is inserted After Begin", "afterbegin")
  25. _IEDocInsertText($oBody, "Notice that <b>Tags</b> are <encoded> before display", "beforeend")
  26.  
  27.  
  28. ; *******************************************************
  29. ; Example 3 - Advanced example
  30. ;        Insert a clock and a referrer string at the top of every page, even when you 
  31. ;        browse to a new location.  Uses _IEDocInsertText, _IEDocInsertHTML and  
  32. ;        _IEPropertySet features "innerhtml" and "referrer"
  33. ; *******************************************************
  34. ;
  35. #include <IE.au3>
  36. $oIE = _IECreate("http://www.autoitscript.com")
  37.  
  38. AdlibEnable("UpdateClock", 1000) ; Update clock once per second
  39.  
  40. ; idle as long as the browser window exists
  41. While WinExists(_IEPropertyGet($oIE, "hwnd"))
  42.     Sleep(10000)
  43. WEnd
  44.  
  45. Exit
  46.  
  47. Func UpdateClock()
  48.     Local $curTime = "<b>Current Time is: </b>" & @HOUR & ":" & @MIN & ":" & @SEC
  49.     ; _IEGetObjByName is expected to return a NoMatch error after navigation 
  50.     ;   (before DIV is inserted), so temporarily turn off notification
  51.     _IEErrorNotify(False)
  52.     Local $oAutoItClock = _IEGetObjByName($oIE, "AutoItClock")
  53.     If Not IsObj($oAutoItClock) Then ; Insert DIV element if it wasn't found
  54.         ;
  55.         ; Get reference to BODY, insert DIV, get reference to DIV, update time
  56.         $oBody = _IETagNameGetCollection($oIE, "body", 0)
  57.         _IEDocInsertHTML($oBody, "<div id='AutoItClock'></div>", "afterbegin")
  58.         $oAutoItClock = _IEGetObjByName($oIE, "AutoItClock")
  59.         _IEPropertySet($oAutoItClock, "innerhtml", $curTime)
  60.         ;
  61.         ; Check referrer string, if not blank insert after clock
  62.         _IELoadWait($oIE)
  63.         $sReferrer = _IEPropertyGet($oIE, "referrer")
  64.         If $sReferrer Then _IEDocInsertText($oAutoItClock, _
  65.             "  Referred by: " & $sReferrer, "afterend")
  66.     Else
  67.         _IEPropertySet($oAutoItClock, "innerhtml", $curTime) ; update time
  68.     EndIf
  69.     _IEErrorNotify(True)
  70. EndFunc